package com.pfzy.utildemo.activity.record;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.pfzy.utildemo.R;
import com.pfzy.utildemo.activity.record.recording.callback.DialogCallBack;
import com.pfzy.utildemo.views.dialog.base.UXMiddleDialog;

/**
 * 录音对话框
 */
public class RecordNormalDialog extends UXMiddleDialog {
    private DialogCallBack mCallBack;

    public RecordNormalDialog(@NonNull Context context, DialogCallBack dialogCallBack) {
        super(context);
        this.mCallBack = dialogCallBack;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setCanceledOnTouchOutside(false);
        setCancelable(false);
    }

    @Override
    protected View createContentView() {
        View contentView = LayoutInflater.from(getContext()).inflate(R.layout.common_dialog_record_normal, (ViewGroup) null);
        contentView.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallBack != null) {
                    mCallBack.cancel();
                }
                dismiss();
            }
        });
        contentView.findViewById(R.id.btn_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallBack != null) {
                    mCallBack.confirm();
                }
                dismiss();
            }
        });
        return contentView;
    }
}
